//
// Created by liushuai on 2021/1/13.
//

#include "solve.h"

std::string solve(int M, int N){
    std::string result = "";
    std::string final_result = "";
    std::vector<char> chars = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
    bool flag = true;
    if(M<0){
        flag = false;
        M = -M;
    }

    while (M){
        int res = M%N;
        result.push_back(chars[res]);
        M/=N;

    }
    if(!flag)
        final_result.push_back('-');
    for(auto iter = result.rbegin();iter!=result.rend();iter++){
        final_result.push_back(*iter);
    }

    return final_result;
}